<template>
  <section>
    <!--工具条-->
    <el-col :span="24" class="toolbar" style="padding-bottom: 0px;">
      <el-form :inline="true" :model="filters">
        <el-form-item>
          <el-input v-model="filters.keyword" placeholder="请输入关键字"></el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" v-on:click="search">查询</el-button>
        </el-form-item>

      </el-form>
    </el-col>

    <!--列表显示-->
    <el-table :data="logs" highlight-current-row v-loading="listLoading"
              @selection-change="selsChange" style="width: 100%;">
      <el-table-column type="selection" width="55">
      </el-table-column>
      <el-table-column type="index" width="60">
      </el-table-column>
      <el-table-column prop="ct" label="创建时间" width="160" sortable>
      </el-table-column>
      <el-table-column prop="ip" label="IP地址" width="120" sortable>
      </el-table-column>
      <el-table-column prop="method" label="调用方法" width="180" sortable>
      </el-table-column>
      <el-table-column prop="param" label="方法参数" min-width="180" sortable>
      </el-table-column>
      <el-table-column prop="operation" label="方法描述" min-width="160" sortable>
      </el-table-column>
      <el-table-column prop="phone" label="账户" min-width="120" sortable>
      </el-table-column>
      <el-table-column prop="time" label="用时" min-width="80" sortable>
      </el-table-column>
    </el-table>

    <!--工具条-->
    <el-col :span="24" class="toolbar">
      <el-pagination layout="prev, pager, next"
                     @current-change="handleCurrentChange"
                     :page-size="pageSize"
                     :total="total"
                     :current-page="currentPage"
                     style="float:right;">
      </el-pagination>
    </el-col>
    
  </section>
</template>

<script>
import util from '../../common/js/util'
//import NProgress from 'nprogress'
import { getDepartmentListPage, removeDepartment, batchRemoveDepartment, editDepartment, addDepartment } from '../../api/api';

export default {
  data() {
    return {
      title:"",//模态框的标题
      filters: {
        keyword: ''
      },
      logs:[],
      deptTree:[],//部门无限级树
      total: 0,
      currentPage: 1,
      pageSize:10,
      listLoading: false,
      sels: [],//当前页 列表选的所有中行

      editFormVisible: false,//编辑界面是否显示
      editLoading: false,
      editFormRules: {//表单校验规则
        name: [//校验name属性
          { required: true, message: '请输入姓名', trigger: 'blur' }
        ],
        sn: [//sn
          { required: true, message: '请输入编号', trigger: 'blur' }
        ]
      }
    }
  },
  methods: {
    search(){//高级查询按钮
      // 定位到第一页
      this.currentPage = 1;
      //调用查询刷新页面
      this.getLogs();
    },
    handleCurrentChange(val) {
      this.currentPage = val;
      this.getLogs();
    },
    selsChange: function (sels) {//每次点击复选框的时候触发函数
      this.sels = sels;
    },
    //获取部门列表
    getLogs() {
      //请求参数
      let para = {
        currentPage: this.currentPage,
        pageSize: this.pageSize,
        keyword: this.filters.keyword//关键字查询
      };
      this.listLoading = true;//开启忙等
      //NProgress.start();
      this.$http.post("/log",para)
          .then(result=>{
            this.listLoading = false;//关闭忙等框
            result = result.data;//PageList
            this.logs = result.rows;
            this.total = result.total;
          })
          .catch(result=>{
            console.log(result);
          })
      /*getDepartmentListPage(para).then((res) => {
        this.total = res.data.total;
        this.logs = res.data.logs;
        this.listLoading = false;
        //NProgress.done();
      });*/
    }
  },
  mounted() {
    this.getLogs();
  }
}

</script>

<style scoped>

</style>